<?php

namespace app\api\controller;


use app\common\model\Manager as ManagerModel;

class Manage extends Base
{


    public function __construct()
    {
        parent::__construct();
    }

    public function login()
    {
        $input = input('');
        if (!$input['name'] || !$input['password']) {
            return returnJson(1, '请填写用户名和密码');
        }
        $manager = ManagerModel::getOne([
            'name' => $input['name']
        ]);
        if (!$manager || createPassword($input['password']) != $manager['password']) {
            return returnJson(1, '密码错误');
        }

        session('manager', $manager);
        return returnJson(200, '登陆成功',$manager);
    }

}

